//
//  YKClientOrderItemCell.m
//  YunKang
//
//  Created by leoking870 on 2017/10/2.
//  Copyright © 2017年 leoking870. All rights reserved.
//

#import "YKClientOrderItemCell.h"
#import "YKDashView.h"
@interface YKClientOrderItemCell ()
@property (weak, nonatomic) IBOutlet UILabel *orderNumberLabel;
@property (weak, nonatomic) IBOutlet UILabel *companyNameLabel;
@property (weak, nonatomic) IBOutlet UILabel *orderStatusLabel;
@property (weak, nonatomic) IBOutlet UILabel *orderDateLabel;

@end

@implementation YKClientOrderItemCell
@dynamic tableViewItem;
- (void)awakeFromNib {
    [super awakeFromNib];
    // Initialization code
}

- (void)cellLoadSubViews {
    [super cellLoadSubViews];
    self.orderNumberLabel.tf_weight = 1;
    self.companyNameLabel.tf_weight = 2;
    self.orderStatusLabel.tf_weight = 1;
    self.orderDateLabel.tf_weight = 1;
    
    if (![self.tableViewItem.istatus isEqualToString:@""]) {
        self.orderStatusLabel.tf_weight = 0;
        self.orderStatusLabel.hidden = YES;
    }
    
    
    NSArray *views = @[self.orderNumberLabel, self.companyNameLabel,  self.orderStatusLabel,self.orderDateLabel];
    if (self.tableViewItem.istatus.length > 0) {
        self.orderStatusLabel.hidden = YES;
        views = @[self.orderNumberLabel, self.companyNameLabel,self.orderDateLabel];
    }
    
    [views mas_makeConstraints:^(MASConstraintMaker *make) {
        make.centerY.equalTo(self.contentView.mas_centerY);
        make.top.equalTo(self.contentView.mas_top).offset(11);
    }];
    
    [views mas_alignWeightlyAlongAxis:MASAxisTypeHorizontal
                                                                                                                 fixedSpace:@2
                                                                                                                  leadingTo:self.contentView.mas_leading
                                                                                                                  leadSpace:13
                                                                                                                 trailingTo:self.contentView.mas_trailing
                                                                                                                  tailSpace:13];
    
    self.orderStatusLabel.textAlignment = NSTextAlignmentCenter;
    self.orderDateLabel.textAlignment = NSTextAlignmentCenter;
    self.companyNameLabel.textAlignment = NSTextAlignmentCenter;
    self.orderStatusLabel.backgroundColor = [UIColor tf_colorWithHexString:@"#fff5e7"];
    self.orderStatusLabel.textColor = [UIColor tf_colorWithHexString:@"#ff8100"];
    self.orderStatusLabel.layer.cornerRadius = 10;
    self.orderStatusLabel.layer.masksToBounds = YES;
    
    
    YKDashView* dashView = [[YKDashView alloc]init];
    dashView.lineWidth = .5f;
    dashView.lineColor = [UIColor tf_colorWithHexString:@"#d4d4d4"];
    dashView.dashLineLength = 3;
    [self addSubview:dashView];
    [dashView mas_makeConstraints:^(MASConstraintMaker *make) {
        make.leading.bottom.trailing.equalTo(self);
        make.height.mas_equalTo(1);
    }];
    
}

- (void)cellWillAppear {
    [super cellWillAppear];
    self.orderNumberLabel.text = self.tableViewItem.model.CSOCODE;
    self.companyNameLabel.text = self.tableViewItem.model.C_NAME;
    
    self.orderDateLabel.text = [[self.tableViewItem.model.DCREATESYSTIME componentsSeparatedByString:@" "]firstObject];

    
    self.orderStatusLabel.text = [self.tableViewItem.model iStatusString];
    
    
}

- (void)setSelected:(BOOL)selected animated:(BOOL)animated {
    [super setSelected:selected animated:animated];

    // Configure the view for the selected state
}

@end
